﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Users.aspx.cs" Inherits="EuroAudit.Users" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Lietotāju saraksts</title>
    <script type="text/javascript">
        //<![CDATA[ 
      function pageLoad() {
      }
      function DelUser() {
          var MessageSource = "cmdDelUsr";
          var MessageText = "Lietotāja dati tiks dzēsti. Vai turpināt?";
          //OpenModal(MessageSource, MessageText);
          document.getElementById("lblDelUser").style.visibility = "visible";
          document.getElementById("cmdDelOKUser").style.visibility = "visible";
          document.getElementById("lblDelGroup").style.visibility = "hidden";
          document.getElementById("cmdDelOKGroup").style.visibility = "hidden";
          overlay();

      }
      function DelGroup() {
          var MessageSource = "cmdDelGroup";
          var MessageText = "Grupa tiks dzēsta. Vai turpināt?";
          //OpenModal(MessageSource, MessageText);
          document.getElementById("lblDelUser").style.visibility = "hidden";
          document.getElementById("cmdDelOKUser").style.visibility = "hidden";
          document.getElementById("lblDelGroup").style.visibility = "visible";
          document.getElementById("cmdDelOKGroup").style.visibility = "visible";
          overlay();

      }
      function OpenModal(MessageSource, MessageText) {
          //var MessageSource = "cmdDel";
          //var MessageText = "Struktūras ieraksts tiks dzēsts. Vai turpināt?";
          var WinSettings = "center:yes;resizable:no;dialogHeight:200px;status:no";
          var RetVal = window.showModalDialog("ModalDlg.aspx", MessageText, WinSettings);
          if (document.getElementById("_RESULT").textContent != "undefined")
              document.getElementById("_RESULT").textContent = RetVal + MessageSource;
          if (document.getElementById("_RESULT").innerText != "undefined")
              document.getElementById("_RESULT").innerText = RetVal + MessageSource;
          //document.getElementById('_RESULT').innerHTML = RetVal + MessageSource;
          __doPostBack("_RESULT", "");
          
          //RefreshIndex();
      }
      function overlay() {
          xyz = document.getElementById("overlay");
          xyz.style.visibility = (xyz.style.visibility == "visible") ? "hidden" : "visible";
          
      }

      //]]> 
    </script>
    <link href="Style.css" rel="stylesheet" type="text/css" />
</head>
<body class="PageMain">


    <form id="form1" runat="server">
    <div id="overlay">
        <div align="center">
            <asp:Label ID="lblDelUser" runat="server" CssClass="LabelFieldCaption" Text="Lietotājs tiks dzēsts. Vai turpināt?"></asp:Label>
            <asp:Label ID="lblDelGroup" runat="server" CssClass="LabelFieldCaption" Text="Grupa tiks dzēsta. Vai turpināt?"></asp:Label>
            <br />
            <asp:Button ID="cmdDelOKUser" runat="server" CssClass="cmdDel" OnClientClick="overlay()"
                OnClick="cmdDelU_Click" Text="OK" />
            <asp:Button ID="cmdDelOKGroup" runat="server" CssClass="cmdDel" OnClientClick="overlay()"
                OnClick="cmdDelG_Click" Text="OK" />
            <asp:Button ID="cmdDelCancel" runat="server" CssClass="cmdClose" OnClientClick="overlay()"
                Text="Cancel" />
        </div>
    </div>
    <div align="center">
        <br />
        <asp:Label ID="Label2" runat="server" CssClass="LabelPageCaption" 
            Text="Lietotāju saraksts"></asp:Label>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
    </div>
    <asp:Button ID="cmdNewU" runat="server" CssClass="cmdNew" 
        onclick="cmdNewU_Click" Text="Jauns lietotājs" Visible="False" />
&nbsp;<asp:Button ID="cmdNewG" runat="server" CssClass="cmdNew" 
        onclick="cmdNewG_Click" Text="Jauna grupa" Visible="False" />
                        <asp:TextBox ID="_RESULT" runat="server" 
            CssClass="FieldsUnvisible"></asp:TextBox>
    <br />
    <asp:UpdatePanel ID="upEdit" runat="server">
        <ContentTemplate>
            <asp:Panel ID="pEditUser" runat="server" CssClass="PanelEdit" Visible="False">
                <asp:TextBox ID="txtNewUser" runat="server" CssClass="FieldsUnvisible">0</asp:TextBox>
                <asp:TextBox ID="txtOldEmail" runat="server" CssClass="FieldsUnvisible"></asp:TextBox>
                <br />
                <asp:Label ID="Label1" runat="server" CssClass="LabelFieldCaption" 
                    Text="Lietotājvārds"></asp:Label>
                <a name="pEditUser"></a>
                <br />
                <asp:TextBox ID="txtUser" runat="server" CssClass="FieldsText"></asp:TextBox>
                <br />
                <asp:Label ID="Label3" runat="server" CssClass="LabelFieldCaption" 
                    Text="Vārds, uzvārds"></asp:Label>
                <br />
                <asp:TextBox ID="txtLongName" runat="server" CssClass="FieldsText"></asp:TextBox>
                <br />
                <asp:Label ID="Label4" runat="server" CssClass="LabelFieldCaption" 
                    Text="Parole"></asp:Label>
                <br />
                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="232px"></asp:TextBox>
                &nbsp;<asp:TextBox ID="txtPassword1" runat="server" TextMode="Password" 
                    Width="232px"></asp:TextBox>
                <br />
                <asp:Label ID="Label5" runat="server" CssClass="LabelFieldCaption" 
                    Text="Apraksts"></asp:Label>
                <br />
                <asp:TextBox ID="txtDescr" runat="server" CssClass="FieldsText"></asp:TextBox>
                <br />
                <asp:Label ID="Label6" runat="server" CssClass="LabelFieldCaption" 
                    Text="E-pasts"></asp:Label>
                <br />
                <asp:TextBox ID="txtEmail" runat="server" CssClass="FieldsText"></asp:TextBox>
                <br />
                <asp:Label ID="Label7" runat="server" CssClass="LabelFieldCaption" 
                    Text="Grupas"></asp:Label>
                <br />
                <asp:TextBox ID="txtGroups" runat="server" CssClass="FieldsText"></asp:TextBox>
                <asp:Button ID="cmdShowG" runat="server" CssClass="cmdShowLists" 
                    onclick="cmdShowG_Click" Text="..." />
                <br />
                <asp:GridView ID="gvGroups" runat="server" AutoGenerateSelectButton="True" 
                    CssClass="TablePopUp"  
                    onselectedindexchanged="gvGroups_SelectedIndexChanged" Visible="False">
                </asp:GridView>
                <asp:SqlDataSource ID="dsGroups" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:WebCNS %>" 
                    ProviderName="<%$ ConnectionStrings:WebCNS.ProviderName %>" 
                    SelectCommand="SELECT GroupName, Description FROM groups WHERE RecStatus=0 ORDER BY GroupName">
                </asp:SqlDataSource>
                <br />
                <div align="center">
                    <asp:Label ID="lblErrU" runat="server" CssClass="LabelError"></asp:Label>
                    <br />
                    <asp:Button ID="cmdSaveU" runat="server" CssClass="cmdSave" 
                        onclick="cmdSaveU_Click" Text="Saglabāt" />
                    &nbsp;<asp:Button ID="cmdDelU" runat="server" CssClass="cmdDel" 
                        onclick="cmdDelU_Click" Text="Dzēst" Visible="False" />
                    <asp:Button ID="cmdDelModUsr" runat="server" CssClass="cmdDel" 
                        onclientclick="DelUser()" Text="Dzēst" />
                    &nbsp;<asp:Button ID="cmdCloseU" runat="server" CssClass="cmdClose" 
                        onclick="cmdCloseU_Click" Text="Aizvērt" />
                </div>
                <br />
            </asp:Panel>
            <asp:Panel ID="pEditGroup" runat="server" CssClass="PanelEdit" Visible="False">
                <asp:TextBox ID="txtGroupID" runat="server" CssClass="FieldsUnvisible"></asp:TextBox>
                <br />
                <asp:Label ID="Label8" runat="server" CssClass="LabelFieldCaption" 
                    Text="Grupas nosaukums"></asp:Label>
                <a name="pEditGroup"></a>
                <br />
                <asp:TextBox ID="txtGroupName" runat="server" CssClass="FieldsText"></asp:TextBox>
                <br />
                <asp:Label ID="Label9" runat="server" CssClass="LabelFieldCaption" 
                    Text="Grupas apraksts"></asp:Label>
                <br />
                <asp:TextBox ID="txtDescription" runat="server" CssClass="FieldsText"></asp:TextBox>
                <br />
                <asp:Label ID="Label12" runat="server" CssClass="LabelFieldCaption" 
                    Text="Lietotāji"></asp:Label>
                <br />
                <asp:TextBox ID="txtUsers" runat="server" CssClass="FieldsText"></asp:TextBox>
                <asp:Button ID="cmdShowU" runat="server" CssClass="cmdShowLists" 
                    onclick="cmdShowU_Click" Text="..." />
                <br />
                <asp:GridView ID="gvUsers" runat="server" AutoGenerateColumns="False" 
                    CssClass="TablePopUp" DataKeyNames="User"  
                    onselectedindexchanged="gvUsers_SelectedIndexChanged" Visible="False">
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="User" HeaderText="User" ReadOnly="True" 
                            SortExpression="User" />
                        <asp:BoundField DataField="LongName" HeaderText="LongName" 
                            SortExpression="LongName" />
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="dsUsers" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:WebCNS %>" 
                    ProviderName="<%$ ConnectionStrings:WebCNS.ProviderName %>" 
                    SelectCommand="SELECT User, LongName FROM users WHERE RecStatus=0 ORDER BY User">
                </asp:SqlDataSource>
                <br />
                <div align="center">
                    <asp:Label ID="lblErrG" runat="server" CssClass="LabelError"></asp:Label>
                    <br />
                    <asp:Button ID="cmdSaveG" runat="server" CssClass="cmdSave" 
                        onclick="cmdSaveG_Click" Text="Saglabāt" />
                    &nbsp;<asp:Button ID="cmdDelG" runat="server" CssClass="cmdDel" 
                        onclick="cmdDelG_Click" Text="Dzēst" Visible="False" />
                    <asp:Button ID="cmdDelModMsg" runat="server" CssClass="cmdDel" 
                        onclientclick="DelGroup()" Text="Dzēst" />
                    &nbsp;<asp:Button ID="cmdCloseG" runat="server" CssClass="cmdClose" 
                        onclick="cmdCloseG_Click" Text="Aizvērt" />
                </div>
                <br />
            </asp:Panel>
            <asp:UpdatePanel ID="upList" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <asp:Label ID="Label10" runat="server" CssClass="LabelFieldCaption" 
                        Text="Lietotāju saraksts"></asp:Label>
                    <br />
                    <asp:Table ID="tUsers" runat="server" CssClass="TableList" GridLines="Both">
                    </asp:Table>
                    <br />
                    <asp:Label ID="Label11" runat="server" CssClass="LabelFieldCaption" 
                        Text="Grupu saraksts"></asp:Label>
                    <br />
                    <asp:Table ID="tGroups" runat="server" CssClass="TableList" GridLines="Both">
                    </asp:Table>
                    <br />
                </ContentTemplate>
            </asp:UpdatePanel>
            <br />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="cmdNewU" EventName="Click">
            </asp:AsyncPostBackTrigger>
            <asp:AsyncPostBackTrigger ControlID="cmdNewG" EventName="Click">
            </asp:AsyncPostBackTrigger>
        </Triggers>
    </asp:UpdatePanel>
    <br />
    <br />
    <br />
    </form>
</body>
</html>
